#include "creditcardprofile.h"

CreditCardProfile::CreditCardProfile(Profile *parent):
    Profile(parent)
{
    parameters_size=5;
    settings_key="CCLastFile";
}

CreditCardProfile::CreditCardProfile(CreditCardProfile & other, Profile *parent):
    CreditCardProfile(parent)
{
    *this=other;
//    m_card_name=other.card_name();
//    m_card_number=other.card_number();
//    m_card_exp_month=other.card_exp_month();
//    m_card_exp_year=other.card_exp_year();
//    m_cvv=other.cvv();
}

CreditCardProfile::~CreditCardProfile()
{

}

QStringList &CreditCardProfile::GetParamList()
{
    data_list.clear();
    data_list<<m_card_name
             <<m_card_number
             <<m_card_exp_month
             <<m_card_exp_year
             <<m_cvv
             <<m_file_name;
    return data_list;
}

void CreditCardProfile::SaveParamsFromList(QStringList &params)
{
    data_list.clear();
    data_list<<params;
    if(params.size()>parameters_size-1)
    {
        m_card_name=params.at(0);
        m_card_number=params.at(1);
        m_card_exp_month=params.at(2);
        m_card_exp_year=params.at(3);
        m_cvv=params.at(4);
    }
}


bool CreditCardProfile::operator==(CreditCardProfile & other) const
{
    if((m_card_name==other.card_name())&&
       (m_card_number==other.card_number())&&
       (m_card_exp_month==other.card_exp_month())&&
       (m_card_exp_year==other.card_exp_year())&&
       (m_cvv==other.cvv()))
        return true;
    else
        return false;
}
CreditCardProfile& CreditCardProfile::operator=( CreditCardProfile & other)
{
    m_card_name=other.card_name();
    m_card_number=other.card_number();
    m_card_exp_month=other.card_exp_month();
    m_card_exp_year=other.card_exp_year();
    m_cvv=other.cvv();
    return *this;
}

//CreditCardProfile& CreditCardProfile::operator const CreditCardProfile()
//{
//    return *this;
//}

void CreditCardProfile::set_card_name(QString card_name)
{
    m_card_name=card_name;
}

void CreditCardProfile::set_card_number(QString card_number)
{
    m_card_number=card_number;
}

void CreditCardProfile::set_cvv(QString cvv)
{
    m_cvv=cvv;
}

void CreditCardProfile::set_card_exp_month(QString card_exp_month)
{
    m_card_exp_month=card_exp_month;
}

void CreditCardProfile::set_card_exp_year(QString card_card_exp_year)
{
    m_card_exp_year=card_card_exp_year;
}

void CreditCardProfile::set_file_name(QString value)
{
    m_file_name=value;
}


QString CreditCardProfile::card_name()
{
    return m_card_name;
}

QString CreditCardProfile::card_number()
{
    return m_card_number;
}

QString CreditCardProfile::cvv()
{
    return m_cvv;
}

QString CreditCardProfile::card_exp_month()
{
    return m_card_exp_month;
}

QString CreditCardProfile::card_exp_year()
{
    return m_card_exp_year;
}

QString CreditCardProfile::file_name()
{
    return m_file_name;
}

QString* CreditCardProfile::StringFromParameters()
{
    QString *str=new QString(
                     m_card_name+"||"
                     +m_card_number+"||"
                     +m_card_exp_month+"||"
                     +m_card_exp_year+"||"
                     +m_cvv);
    return str;
}
